<html>
<html>
<head>
<style type="text/css">
body , input , select {
	font-family:Tahoma, Verdana, Arial;
	font-size:12px;
}
.code {
	width:95%;
	height:200px;
	padding:5px;
	border:1px solid #cccccc;
	font-family:"Courier new", "Times new roman", Arial;
	font-size:11px;
	line-height:18px;
	overflow:auto;
	
}

.copyclip {
	display:block;
	margin:5px 0 10px 0;
}
</style>

</head>
<body>



<script language="javascript">
function copyToClipboard(s)
{
	clipboardData.setData("Text", s);
}
</script>


<?php
require_once('adodb/adodb.inc.php'); 
require_once('DBGenerator2-functions.php'); 

$fields_prefix = "mx_";

$conn =& ADONewConnection('mysql');	
$conn->Connect('localhost','root','','prepprofiles');
$conn->SetFetchMode(ADODB_FETCH_ASSOC); 


$ignorefields = array("Added");
$autoUpdateVal = array("idUser"=>"getLoggedUserID()");

$table = $_GET['table'];

if (!empty($table)) {
	
	$mod_name = (empty($_GET['modname'])?$table:$_GET['modname']);
	
	$tablefields=$conn->MetaColumns($_GET['table']);	
	
	echo("<h1>Definition for table ".$_GET['table'].":</h1><BR>");
	
	?>
	<form action="DBGenerator2.php" method="GET">
		<input type="hidden" name="table" value="<?=$table?>" \>
		Rename module <input type="text" maxlength="50" size="20" name="modname" value="<?=$mod_name?>"> <input type="submit" value="rename">
	</form>
	<?

	$pk=$conn->MetaPrimaryKeys($_GET['table']);
	
	$pk_list_with_prefix="";	//PK fields list with prefix
	
	$pk_list_with_prefix_JS_func_param="";	//PK list params to be used on a JS function param declaration
	$pk_list_with_prefix_JS_func_call="";	//PK list params to be used on a JS function call (assuming $r the array object)
	$pk_list_with_prefix_JS_QS_call="";		//PK list params to be used inside a JS function to append to a URL QS
	$pk_list_with_prefix_HTML_QS_call="";	//PK list params to be used inside an HTML link to append to a URL QS
	
	$pk_list_for_ids_array="";
	$isfirst=true;
	foreach ($pk as $p) {
		$pk_list_with_prefix[]='$'.$fields_prefix.$p;

		$pk_list_with_prefix_JS_func_call[]  = 	'\'<?=htmlentities($r[\''.$p.'\'])?>\'';
		
		$pk_list_with_prefix_JS_QS_call[]    = 	" + '&$fields_prefix$p=' + escape($fields_prefix$p)";
		
		$pk_list_with_prefix_JS_func_param[] =	$fields_prefix.$p;

		$pk_list_with_prefix_HTML_QS_call[]  = 	"$fields_prefix$p=<?=htmlentities(\$r['$p'])?>";
		
		
		if (!$isfirst) {
			$pk_list_for_ids_array .= ",";
			$pk_list_for_ids_array .= "\n";
		}
		$pk_list_for_ids_array .="		\"`$p`\" => \$$fields_prefix$p";
		$isfirst=false;
	}
	$pk_list_with_prefix = implode(", " , $pk_list_with_prefix);
	$pk_list_with_prefix_JS_func_param = implode(", " , $pk_list_with_prefix_JS_func_param);
	$pk_list_with_prefix_JS_func_call = implode(", " , $pk_list_with_prefix_JS_func_call);
	$pk_list_with_prefix_JS_QS_call = implode(" " , $pk_list_with_prefix_JS_QS_call);
	$pk_list_with_prefix_HTML_QS_call = implode("&" , $pk_list_with_prefix_HTML_QS_call);
	
	
	//----------------------------------------------------------------------------------------------------
	//ACTION: INSERT
	//----------------------------------------------------------------------------------------------------
	echo ("<h2>INSERT ACTION</h2>
	<div class='code' id='ia'><?\n");
	
	
	//Retrieve POST values
	$buf = "<?\n";
	foreach ($tablefields as $f) {
		$maxlen="";
		$field = $f->name;
		$len = $f->max_length;
		
		if (in_array($f->name ,$pk)) continue;
		if (in_array($f->name ,$ignorefields)) continue;
		if (isset($autoUpdateVal[$f->name])) continue;
		
		
		if (isTextField($f->type))
			$len = 65536;
		elseif (isLongTextField($f->type))
			$len = 2000000000;
		
		if (isCharField($f->type)) {
				$buf .= "\$$fields_prefix$field = getParameterStringSanitized(\$_POST , '$fields_prefix$field' , $len);\n";
				$buf .="if (empty(\$$fields_prefix$field))
	\$globalErrorMessage[] = '$field';\n\n";
		}
		elseif (isNumericField($f->type)) {
				$buf .="\$$fields_prefix$field = getParameterInt(\$_POST , '$fields_prefix$field');\n";
				$buf .="if (empty(\$$fields_prefix$field))
	\$globalErrorMessage[] = '$field';\n\n";
		}
		elseif (isBoolField($f->type)) {
				$buf .= "\$$fields_prefix$field = getParameterBool(\$_POST , '$fields_prefix$field');\n\n";
				$isBit=true;
		}
		elseif (isDateField($f->type)) {
				$buf .= "\$$fields_prefix$field = getParameterDate(\$_POST , '$fields_prefix$field');\n";
				$buf .= "if (empty(\$$fields_prefix$field))
	\$globalErrorMessage[] = '$field';\n\n";
		}
		else {
				$buf .=("[TYPE NOT FOUND]: " . $f->type . " - Field: " . $f->name) . "
";
		}
	}
	
	
	
	//Insert logic
	$buf .= "
if (!isset(\$globalErrorMessage)) {
	\$data = array(
";

	$isfirst = true;
	foreach ($tablefields as $f) {
		$field = $f->name;
		if (in_array($f->name ,$pk)) continue;
		if (in_array($f->name ,$ignorefields)) continue;

		if (!$isfirst)
			$buf .=  ",\n";
		
		if (isset($autoUpdateVal[$f->name])) 
			$buf .= "		\"`$field`\" => " . $autoUpdateVal[$f->name];
		else
			$buf .= "		\"`$field`\" => \$$fields_prefix$field";
		
			
		$isfirst = false;
	}
	$buf .=  "
	);
	
	\$id = db_exec_insert(\"$table\",\$data);
	\$_SESSION['globalInfoMessage']=\"The record was succesfully posted\";
	sendRedirect(\"index.php?mod=$mod_name\");	
}

\$_GET['mod'] = '$mod_name';
include(\"index.php\")";
	
	$buf .= "\n?>";
	
	highlight_string($buf);
	echo "</div>
	<a href=\"javascript:copyToClipboard(document.getElementById('ia').innerText);\" class='copyclip'>copy</a>";

	
	
	
	
	
	
	
	//----------------------------------------------------------------------------------------------------
	//FORM: INSERT
	//----------------------------------------------------------------------------------------------------
	$buf="";
	echo("<h2>INSERT FORM</h2>
	<div class='code' id='if'>\n");
		$buf .= "<?include(\"inc/messages.php\");?>

<div id=\"mx-newpostlink\"><a style=\"cursor:pointer; text-decoration:underline\" id=\"mx-addnewrecord\" class=\"mx-addnewrecord\">Add New</a></div>
<div style=\"<?=empty(\$_POST['action'])?\"display:none;\":\"\"?>\" id=\"mx-newpostdiv\">

<form action=\"controller.php\" method=\"POST\" id=\"mx-newpostform\" name=\"mx-newpostform\">

<input type=\"hidden\" name=\"action\" value=\"".$mod_name."_add\" \\>
<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\">
";
	foreach ($tablefields as $f) {
		if (in_array($f->name ,$pk)) continue;
		if (in_array($f->name ,$ignorefields)) continue;
		if (isset($autoUpdateVal[$f->name])) continue;
		
		$buf .= renderField($f);
		
	}

	$buf .='<tr>
	<td></td>
	<td align="left"><br>
	<span class="mx-required">*</span> denotes a required field<br>
	<br>
	<input type="submit" class="mx-submitbtn" value="submit" />&nbsp;
	<input id="mx-hidenewpost" type="button" class="mx-submitbtngray" value="cancel" />
	</td>
</tr>
</table>
</form>
</div>

<script language="javascript">
$(document).ready(function(){
	$("#mx-newpostlink").click(function () {
	  $("#mx-newpostdiv").show("fast");
	});

	$("#mx-hidenewpost").click(function () {
	  $("#mx-newpostdiv").hide("fast");
	});
	
});

function deletepost('.$pk_list_with_prefix_JS_func_param.') {
	if (confirm("Are you sure to delete the record?"))
		document.location = \'controller.php?action='.$mod_name.'_delete\''.$pk_list_with_prefix_JS_QS_call.';
}
</script>


<?
$qtyRows = get'.$table.'Rs(true);
if ($qtyRows==0) {
		?>
		<div id="mx-norecords">There are no records created yet.</div>
		<?
}
else {
	$pagesize = 25;

	$pages = ceil($qtyRows / $pagesize);

	$current_page=getParameterInt($_GET,\'page\');
	if ($current_page<1) $current_page=1;
	if ($current_page>$pages) $current_page = $pages;
	$limit = " LIMIT " . (($current_page-1)*$pagesize) . "," . $pagesize;

	$records = get'.$table.'Rs(false,"","",$limit);
	?>
	<table cellpadding="4" cellspacing="0" border="0" id="mx-listing">
	<tr>
		<th>Title</th>
		<th colspan="2" class="mx-actions">Actions</th>
	</tr>
	<?
	$i=1;
	while ($r = mysql_fetch_array($records)) {
		$cl="";
		if (($i%2)==0) $cl=\' class="mx-alternate"\';
		?>
		<tr>
			<td<?=$cl?>><?=breakLongWords($r[\'Title\'])?></td>
			<td<?=$cl?>><a href="index.php?mod='.$mod_name.'_edit&'.$pk_list_with_prefix_HTML_QS_call.'" class="mx-edit">edit</a></td>
			<td<?=$cl?>><a href="javascript:deletepost(<?=$r[\'id\']?>)" class="mx-delete">delete</a></td>
		</tr>
		<?
		$i++;
	}?>
	</table>
	
	<br>
	<?	
	if ($qtyRows>0) {?>
		<div id="mx-paging-div">
		<?=$qtyRows?> record<?=$qtyRows>0?"s":""?> found<br><br>
		<?
		if ($pages>1) {?>
		
			<?
			if ($current_page>1) {
				?>
				<span class="mx-paging-item"><a href="index.php?mod='.$mod_name.'&page=<?=$current_page-1?>">&laquo; Previous</a></span>
				<?
			}
			for ($i=1;$i<=$pages;$i++) {
				if ($current_page==$i) {
					?>
					<span class="mx-paging-disabled"><?=$i?></span>
					<?
				}
				else {
					?>
					<span class="mx-paging-item"><a href="index.php?mod='.$mod_name.'&page=<?=$i?>"><?=$i?></a></span>
					<?
				}
			}
			if ($current_page < $pages) {
				?>
				<span class="mx-paging-item"><a href="index.php?mod='.$mod_name.'&page=<?=$current_page+1?>">Next &raquo; </a></span>
				<?
			}?>
			<br><br>
		<?
		}?>
		</div>
	<?}?>	
<?}?>

';
	
	highlight_string($buf);
	echo "</div>
	<a href=\"javascript:copyToClipboard(document.getElementById('if').innerText);\" class='copyclip'>copy</a>";
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	//----------------------------------------------------------------------------------------------------
	//ACTION: UPDATE
	//----------------------------------------------------------------------------------------------------
	echo("<h2>UPDATE ACTION</h2>
	<div class='code' id='ua'>");
	
	$buf="<?\n";
	
	//Retrieve POST values
	foreach ($tablefields as $f) {
		$maxlen="";
		$field = $f->name;
		$len = $f->max_length;
		
		if (in_array($f->name ,$ignorefields)) continue;
		if (isset($autoUpdateVal[$f->name])) continue;
		
		
		if (isTextField($f->type))
			$len = 65536;
		elseif (isLongTextField($f->type))
			$len = 2000000000;
		
		if (isCharField($f->type)) {
				$buf .= "\$$fields_prefix$field = getParameterStringSanitized(\$_POST , '$fields_prefix$field' , $len);\n";
				$buf .= "if (empty(\$$fields_prefix$field))
	\$globalErrorMessage[] = '$field';\n\n";
		}
		elseif (isNumericField($f->type)) {
				$buf .= "\$$fields_prefix$field = getParameterInt(\$_POST , '$fields_prefix$field');\n";
				$buf .= "if (empty(\$$fields_prefix$field))
	\$globalErrorMessage[] = '$field';\n\n";
		}
		elseif (isBoolField($f->type)) {
				$buf .= "\$$fields_prefix$field = getParameterBool(\$_POST , '$fields_prefix$field');\n\n";
				$isBit=true;
		}
		elseif (isDateField($f->type)) {
				$buf .= "\$$fields_prefix$field = getParameterDate(\$_POST , '$fields_prefix$field');\n";
				$buf .= "if (empty(\$$fields_prefix$field))
	\$globalErrorMessage[] = '$field';\n\n";
		}
		else {
				$buf .= "[TYPE NOT FOUND]: " . $f->type . " - Field: " . $f->name . "
";
		}
	}
	
	
	
	//Update logic
	$buf .= "
if (!isset(\$globalErrorMessage)) {
	\$data = array(
";
	$isfirst = true;
	foreach ($tablefields as $f) {
		$field = $f->name;
		if (in_array($f->name ,$pk)) continue;
		if (in_array($f->name ,$ignorefields)) continue;
		if (isset($autoUpdateVal[$f->name])) continue;

		if (!$isfirst)
			$buf .=  ",\n";

		$buf .= "		\"`$field`\" => \$$fields_prefix$field";
		
		$isfirst = false;
	}
		
	
	$buf .= "	
);
	
	\$ids = array(
";
	$buf .= $pk_list_for_ids_array;
	$isfirst = empty($pk_list_for_ids_array);
	
	foreach ($autoUpdateVal as $f=>$val) {
		
		if (!isset($tablefields[strtoupper($f)])) continue;
		
		$field = $f;

		if (!$isfirst)
			$buf .= ",\n";
		$buf .= "		\"`$field`\" => $val";

		$isfirst = false;
	}
		
	
	$buf .= "\n	);
	
	\$id = db_exec_update(\"$table\",\$data,\$ids);
	\$_SESSION['globalInfoMessage']=\"The record was succesfully updated\";
	sendRedirect(\"index.php?mod=$mod_name\");	
}

\$_GET['mod'] = '$mod_name"."_edit';
include(\"index.php\")
?>";
	
	highlight_string($buf);
	echo "</div>
	<a href=\"javascript:copyToClipboard(document.getElementById('ua').innerText);\" class='copyclip'>copy</a>";

	
	
	
	

	
	

	
	
	
	//----------------------------------------------------------------------------------------------------
	//FORM: UPDATE
	//----------------------------------------------------------------------------------------------------
	$formhiddens="";
	echo '<h2>UPDATE FORM</h2>
	<div class=\'code\' id="uf">';

	$buf="";
	
	$buf .= '<?
if (!isset($_POST["action"])) {
';

	//Retrieve POST values
	foreach ($pk as $f) {
		$f = $tablefields[strtoupper($f)];
		$field = $f->name;

		$formhiddens .= "<input type=\"hidden\" name=\"$fields_prefix$field\" value=\"<?=\$$fields_prefix$field?>\" \\>\n";
		
		if (isTextField($f->type))
			$len = 65536;
		elseif (isLongTextField($f->type))
			$len = 2000000000;
		
		if (isCharField($f->type)) {
				$buf .="	\$$fields_prefix$field = getParameterStringSanitized(\$_GET , '$fields_prefix$field' , $len);\n";
				$buf .="	if (empty(\$$fields_prefix$field)) die(\"Invalid call\");\n";
		}
		elseif (isNumericField($f->type)) {
				$buf .="	\$$fields_prefix$field = getParameterInt(\$_GET , '$fields_prefix$field');\n";
				$buf .="	if (empty(\$$fields_prefix$field)) die(\"Invalid call\");\n";
		}
		elseif (isBoolField($f->type)) {
				$buf .="	\$$fields_prefix$field = getParameterBool(\$_GET , '$fields_prefix$field');\nn";
				$isBit=true;
		}
		elseif (isDateField($f->type)) {
				$buf .="	\$$fields_prefix$field = getParameterDate(\$_GET , '$fields_prefix$field');\n";
				$buf .="	if (empty(\$$fields_prefix$field)) die(\"Invalid call\");\n";
		}
		else {
				$buf .="	[TYPE NOT FOUND]: " . $f->type . " - Field: " . $f->name . "
";
		}
	}
	
	
	$buf .= '
	if ($r = get'.$table.'ById('.$pk_list_with_prefix.')) {
';

	foreach ($tablefields as $f) {
		if (in_array($f->name ,$pk)) continue;
		if (in_array($f->name ,$ignorefields)) continue;
		if (isset($autoUpdateVal[$f->name])) continue;

		$field = $f->name;
		
		$buf .= "		\$$fields_prefix$field = \$r['$field'];\n";
	}
	
	$buf .= '	}
}
?>

';
	
	
	$buf .= "<?include(\"inc/messages.php\");?> 
	
<div id=\"mx-editpostdiv\"> 
<form action=\"controller.php\" method=\"POST\" id=\"editpostform\" name=\"editpostform\">
<input type=\"hidden\" name=\"action\" value=\"".$mod_name."_edit\" \\>
$formhiddens
<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\">
";
	foreach ($tablefields as $f) {
		if (in_array($f->name ,$pk)) continue;
		if (in_array($f->name ,$ignorefields)) continue;
		if (isset($autoUpdateVal[$f->name])) continue;

		$buf .= renderField($f);
	}
	
	$buf .= '<tr>
	<td></td>
	<td align="left"><br>

	<span class="mx-required">*</span> denotes a required field<br>
	<br>
	<input type="submit" class="mx-submitbtn" value="update" />&nbsp;<input id="hidenewpost" type="button" class="mx-submitbtngray" value="cancel" />
	</td>
</tr>
</table>
</form>
</div>

<script language="javascript">
$(document).ready(function(){
	$("#hidenewpost").click(function () {
	  document.location = \'index.php?mod='.$mod_name.'\';
	});
	
});
</script>';
	
	highlight_string($buf);
	echo "</div>
	<a href=\"javascript:copyToClipboard(document.getElementById('uf').innerText);\" class='copyclip'>copy</a>";


	
		
	
	
	
	
	
	
	
	
	//----------------------------------------------------------------------------------------------------
	//ACTION: DELETE
	//----------------------------------------------------------------------------------------------------
	echo '<h2>DELETE ACTION</h2>
	<div class=\'code\' id="da">';

	$buf="<?\n";
	
	
	//Retrieve POST values
	foreach ($pk as $f) {
		$f = $tablefields[strtoupper($f)];
		$field = $f->name;
		
		if (isTextField($f->type))
			$len = 65536;
		elseif (isLongTextField($f->type))
			$len = 2000000000;
		
		if (isCharField($f->type)) {
				$buf .="\$$fields_prefix$field = getParameterStringSanitized(\$_GET , '$fields_prefix$field' , $len);\n";
				$buf .="if (empty(\$$fields_prefix$field)) die(\"Invalid call\");\n\n";
		}
		elseif (isNumericField($f->type)) {
				$buf .="\$$fields_prefix$field = getParameterInt(\$_GET , '$fields_prefix$field');\n";
				$buf .="if (empty(\$$fields_prefix$field)) die(\"Invalid call\");\n\n";
		}
		elseif (isBoolField($f->type)) {
				$buf .="\$$fields_prefix$field = getParameterBool(\$_GET , '$fields_prefix$field');\n\n";
				$isBit=true;
		}
		elseif (isDateField($f->type)) {
				$buf .="\$$fields_prefix$field = getParameterDate(\$_GET , '$fields_prefix$field');\n";
				$buf .="if (empty(\$$fields_prefix$field)) die(\"Invalid call\");\n\n";
		}
		else {
				$buf .="[TYPE NOT FOUND]: " . $f->type . " - Field: " . $f->name . "
";
		}
	}
	
	
	
	//Delete logic
	$buf .= "
\$data = array(
";
	$buf .= $pk_list_for_ids_array;
	$isfirst = empty($pk_list_for_ids_array);

	foreach ($autoUpdateVal as $f=>$val) {
		
		if (!isset($tablefields[strtoupper($f)])) continue;
		
		$field = $f;

		if (!$isfirst)
			$buf .= ",\n";
		$buf .= "	\"`$field`\" => $val";

		$isfirst = false;
	}
		
	
	$buf .= "\n);
	
\$id = db_exec_delete(\"$table\",\$data);
\$_SESSION['globalInfoMessage']=\"The record was succesfully deleted\";
sendRedirect(\"index.php?mod=$mod_name\");
?>";

	
	highlight_string($buf);
	echo "</div>
	<a href=\"javascript:copyToClipboard(document.getElementById('da').innerText);\" class='copyclip'>copy</a>";

		

	
	
	
		

	
	
	
	
	
	//----------------------------------------------------------------------------------------------------
	//EXTRA FUNCTIONS
	//----------------------------------------------------------------------------------------------------
	echo '<h2>EXTRA FUNCTIONS</h2>
	<div class=\'code\' id="ef">';

	$buf="";
	
	$buf .= '<?
function get'.$table.'ById('.$pk_list_with_prefix.') {
	$data = array(
';
	$buf .= $pk_list_for_ids_array;

	$isfirst = empty($pk_list_for_ids_array);

	foreach ($autoUpdateVal as $f=>$val) {
		
		if (!isset($tablefields[strtoupper($f)])) continue;
		
		$field = $f;

		if (!$isfirst)
			$buf .= ",\n";
		$buf .= "	\"`$field`\" => $val";

		$isfirst = false;
	}
	
	$buf .= '
	);
	$rs = db_exec_select("*" , "'.$table.'", $data);
	if ($rs)
		return mysql_fetch_array($rs);
	else
		return false;
}

function get'.$table.'Rs($onlyCount=false , $where="" , $order="" , $limit="") {

	';


	$tmpbuf="\$extrawhere = array(
";
	$isfirst = true;
	foreach ($autoUpdateVal as $f=>$val) {
		
		if (!isset($tablefields[strtoupper($f)])) continue;
		
		$field = $f;

		if (!$isfirst)
			$buf .= ",\n";
		$tmpbuf .= "		\"`$field`\" => $val";

		$isfirst = false;
	}
	$tmpbuf .= "\n";
	
$tmpbuf .= '	);';

	
	
	
	$buf .= $tmpbuf . '

	if (is_array($where)) 
		$where = array_merge($where , $tmpbuf);
	else
		$where = $tmpbuf;
	
	$rs = db_exec_select( ($onlyCount?"count(*) as q":"*") , "'.$table.'", $where , $order , $limit);
	if ($onlyCount) {
		if ($r = mysql_fetch_array($rs))
			return $r["q"];
		else
			return 0;
	}
	else {
		if ($rs)
			return $rs;
		else
			return false;
	}
}
?>';
	
	highlight_string($buf);
	echo "</div>
	<a href=\"javascript:copyToClipboard(document.getElementById('ef').innerText);\" class='copyclip'>copy</a>";
	
	

	
	
	
		

	
	
	
	
	
	//----------------------------------------------------------------------------------------------------
	//CONTROLLER & MODULE DEFS
	//----------------------------------------------------------------------------------------------------
	echo '<h2>CONTROLLER & MODULE DEFS</h2>
	<div class=\'code\' id="ca">';

	$buf="";
	
	$buf .= "<?
//------------------ CONTROLLER ------------------
\$actions = array(
	\"".$mod_name."_add\" => \"actions/".$mod_name."_add.php\",
	\"".$mod_name."_edit\" => \"actions/".$mod_name."_edit.php\",
	\"".$mod_name."_delete\" => \"actions/".$mod_name."_delete.php\",

	\"dummy\" => \"dummy\"
);



//------------------ MODULE ------------------
\$mods['".$mod_name."'] = 'modules/$mod_name/".$mod_name.".php';
\$requieres_loguedin['back_pics'] = '1';

\$mods['".$mod_name."_edit'] = 'modules/$mod_name/".$mod_name."_edit.php';
\$requieres_loguedin['back_pics_edit'] = '1';
?>";
	
	highlight_string($buf);
	echo "</div>
	<a href=\"javascript:copyToClipboard(document.getElementById('ca').innerText);\" class='copyclip'>copy</a>";
	
		
} 




echo("<BR><BR><h1>Available tables:</h1><BR>");
foreach ($conn->MetaTables('TABLES') as $table) {
	echo("<a href='?table=$table'>$table</a><br>");	
}

$conn->Close();
?>


</body>
</html>

